package day15.atm;

import day9.atm.User;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 查询界面
 */
public class SearchPanel extends JPanel implements ActionListener {
    private ATMFrame atmFrame;
    private ImageIcon saveImg = new ImageIcon("images/buttonOff.jpg");

    private JLabel saveLabel = new JLabel();
    private Font font = new Font("黑体",Font.BOLD,30);
    private JButton saveButton = new JButton(saveImg);

    public SearchPanel(ATMFrame atmFrame){
        this.atmFrame = atmFrame;
        this.setLayout(null);
        saveLabel.setBounds(300,200,300,50);
        saveButton.setBounds(884,600,140,50);
        saveButton.addActionListener(this);
        saveLabel.setFont(font);
        this.add(saveLabel);
        this.add(saveButton);
        this.setOpaque(false);
    }
    public void showBlance(double blance){
        saveLabel.setText("你的余额为：" + blance);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == saveButton){
                atmFrame.switchPanel("menu");
        }
    }
}
